package frame 
{
	import frame.edit.RecordGroup;
	import frame.edit.RecordStaff;
	import frame.edit.RecordTime;
	import frame.exec.ExecPage;
	import ui.ui_button;
	import ui.uiWin;
	import nsdecl.ns_interactive_slot;
	
	/**
	 * 界面首页
	 * @author anod
	 */
	public class MainPage extends uiWin implements IFrame
	{
		use namespace ns_interactive_slot;
		
		private var mFrame:FMainPage;
		private var mPanel:uiWin;
		
		/**
		 * 几个子面板
		 */
		private var mPanelRecordStaff:RecordStaff;
		private var mPanelRecordGroup:RecordGroup;
		private var mPanelRecordTime:RecordTime;
		private var mPanelExecute:ExecPage;
		
		public function MainPage() 
		{
			mFrame = new FMainPage();
			addChild( mFrame );
			super();
			
			mPanelRecordStaff = new RecordStaff();
			mPanelRecordGroup = new RecordGroup();
			mPanelRecordTime  = new RecordTime();
			mPanelExecute     = new ExecPage();
			
			setupInteractive();
			setupDataMonitor();
		}
		
		/* INTERFACE frame.IFrame */
		
		public function setupInteractive():void 
		{
			recordStaffButton.click = "recordStaff";
			recordGroupButton.click = "recordGroup";
			recordTimeButton.click  = "recordTime";
			arrangeButton.click     = "executeArrange";
		}
		
		public function setupDataMonitor():void 
		{
			
		}
		
		//主功能服务
		//------------------------------------
		ns_interactive_slot function switchChild( panel:Object ):void
		{
			switchChildPanel( panel as uiWin );
		}
		private function switchChildPanel( panel:uiWin ):void
		{
			mPanel && mPanel.parent && mPanel.onClose();
			
			mPanel = panel;
			
			mFrame.visible = true;
			mPanel && ( (mFrame.visible = false) || addChild( mPanel ) );
		}
		
		//交互回调定义
		//------------------------------------
		
		/** click slot for recordStaffButton */
		ns_interactive_slot function recordStaff( btn:ui_button ):void
		{
			switchChild( mPanelRecordStaff );
		}
		
		/** click slot for recordGroupButton */
		ns_interactive_slot function recordGroup( btn:ui_button ):void
		{
			switchChild( mPanelRecordGroup );
		}
		
		/** click slot for recordTimeButton */
		ns_interactive_slot function recordTime( btn:ui_button ):void
		{
			switchChild( mPanelRecordTime );
		}
		
		/** click slot for arrangeButton */
		ns_interactive_slot function executeArrange( btn:ui_button ):void
		{
			switchChild( mPanelExecute );
		}
		
		//交互组件定义
		//------------------------------------
		public function get recordStaffButton():ui_button
		{
			return mFrame.iRecordStaffButton.component;
		}
		public function get recordGroupButton():ui_button
		{
			return mFrame.iRecordGroupButton.component;
		}
		public function get recordTimeButton():ui_button
		{
			return mFrame.iRecordTimeButton.component;
		}
		public function get arrangeButton():ui_button
		{
			return mFrame.iArrangeButton.component;
		}
	}

}